#include <iostream>
#include <vector>
#include <unordered_set>
using namespace std;

class Solution {
public:
    int takeAttendance(vector<int>& records)
    {
        unordered_set<int> s;
        int n = records.size();
        s.reserve(n + 1);
        for (int i = 0; i < n; i++)
        {
            s.emplace(records[i]);
        }

        for (int i = 0; i <= n; i++)
        {
            if (!s.count(i))
            {
                return i;
            }
        }
        return -1;
    }
};

int main()
{
    Solution s;
    vector<int> v = { 0,1,2,3,5 };
    cout << s.takeAttendance(v) << endl;
    return 0;
}